-- fixed_damage
-- create by wangy
-- 造成N%伤害

return {
    apply = function(source, target, skillId, round, para, value)
        -- 造成N%伤害
        local damage = value[1];
        local cure = value[2];
        local debuff = value[3];
        target:receiveDamage(damage);
        trace("fixed_damage", "%s 受到 %d 点伤害，当前生命值 %d",
            target:getName(), damage, target:queryAttrib("hp"));

        -- 尝试吸血
        if cure > 0 then
            source:addAttrib("hp", cure);
            trace("fixed_damage", "%s 回复 %d 点生命，当前生命值 %d", source:getName(), cure, source:queryAttrib("hp"));
        end

        if #debuff > 0 then
            -- 记录属性
            PropM.recordDebuff(target, debuff);
        end

        return { ["damage"] = damage, ["cure"] = cure, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), tonumber(arr[2]), };
    end,

    getDetail = function(para)
        local desc;
        local value = para[1] / 10;
        -- 分为破防和不破防
        if para[2] == 0 then
            desc = string.format(getLocStr("shipskill_fixed_damage_1"), value);
        elseif para[2] == 1 then
            desc = string.format(getLocStr("shipskill_fixed_damage_2"), value);
        end

        return desc;
    end,

    parseDesc = function(desc, para)
        -- 伤害，每次替换一个
        return string.gsub(desc, "{damage}", math.modf(para[1] / 10), 1);
    end,
};
